<?php

use App\Constant\CommissionEnum;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddColumnSourceToCommissionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('commissions', function (Blueprint $table) {
            $table->tinyInteger('by_groups')->index()->default(0)->after('child_user_withdraw_at');
            $table->string('source', 20)->default(CommissionEnum::SOURCE_NORMAL_INVITE)->after('child_user_withdraw_at');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('commissions', function (Blueprint $table) {
            $table->dropColumn('by_groups');
            $table->dropColumn('source');
        });
    }
}
